package com.batata.continuing.service.common;

import com.batata.continuing.pojo.base.ResultData;

public class ResultCommon {


    public static ResultData<Object> getObjectResultData(ResultData<Object> resultData, int insertCount) {
        if (insertCount == 1) {
            // 插入成功
            resultData.setCode(200);
            resultData.setMessage("创建成功");
            resultData.setSuccess(true);
        } else {
            resultData.setCode(500);
            resultData.setMessage("创建失败");
            resultData.setSuccess(false);
        }


        return resultData;
    }

    public static ResultData<Object> resultDataCommon(Integer code, String msg, boolean success) {
        ResultData<Object> resultData = new ResultData<>();
        resultData.setCode(code);
        resultData.setMessage(msg);
        resultData.setSuccess(success);
        return resultData;
    }

    public static ResultData<?> resultDataCommon(Integer code, String msg, boolean success, Object data) {
        ResultData<Object> resultData = resultDataCommon(code, msg, success);
        resultData.setData(data);
        return resultData;
    }


}
